package com.bw.demo.valid.anno;

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE_USE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

import com.bw.demo.valid.validator.EnumConstraintValidator;

/**
 * 对枚举进行校验
 * @author tao zhisheng
 *
 */
@Documented
@Constraint(validatedBy = { EnumConstraintValidator.class })
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
@Retention(RUNTIME)
public @interface EnumValid {
	
	String message() default "";

	Class<?>[] groups() default { };

	Class<? extends Payload>[] payload() default { };
	
	/**
	 * 目标枚举类
	 * @return
	 */
	Class<?> target();
	
	/**
	 * 需要校验的目标枚举类中的字段名，该枚举中需要有该字段的get方法
	 * @return
	 */
	String enumType() default "value";
}
